package com.honvay.cola.auth.social.qq.config;

import com.honvay.cola.auth.social.qq.QQProperties;
import com.honvay.cola.auth.social.qq.connect.QQConnectionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.social.config.annotation.ConnectionFactoryConfigurer;
import org.springframework.social.config.annotation.SocialConfigurerAdapter;
import org.springframework.social.connect.ConnectionFactory;
import org.springframework.social.connect.ConnectionFactoryLocator;
import org.springframework.social.connect.UsersConnectionRepository;

/**
 * @author LIQIU
 */
@Configuration
@EnableConfigurationProperties(QQProperties.class)
public class QQConnectConfiguration extends SocialConfigurerAdapter {

	@Autowired
	private QQProperties qqProperties;


	@Override
	public void addConnectionFactories(ConnectionFactoryConfigurer connectionFactoryConfigurer, Environment environment) {
		QQConnectionFactory qqConnectionFactory = new QQConnectionFactory(qqProperties.getProviderId(), qqProperties.getAppId(), qqProperties.getAppSecret());
		connectionFactoryConfigurer.addConnectionFactory(qqConnectionFactory);
	}
}